<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns:ui="http://java.sun.com/jsf/facelets"
                template="../../Templates/SubFolderTemplate.xhtml"
                xmlns:p="http://primefaces.prime.com.tr/ui"
                xmlns:h="http://java.sun.com/jsf/html"
                xmlns:f="http://java.sun.com/jsf/core">
    <ui:define name="head-title">
        <title>Add Cash In Advance for Customer | Merlion's ERP System</title>
    </ui:define>
    
    
    <ui:define name="content">
        <f:view beforePhase="#{refundCashInAdvanceManagerBean.initView}">
        <h:form>
            <p:panel id="panel" header="Refund Cash In Advance for Customer"> 
                <p:ajaxStatus style="width:16px;height:16px;">   
                    <f:facet name="start">   
                        <p:graphicImage value="http://www.primefaces.org:8080/showcase/design/ajaxloading.gif" /> 
                    </f:facet> 
 
                    <f:facet name="complete">   
                        <h:outputText value="" />   
                    </f:facet>   
                </p:ajaxStatus> 
 
                <p:messages /> 
 
                <h:outputLabel for="saleOrderId" style="font-weight: bold" value="Sale Order ID: " /> 
                <h:outputText id="saleOrderId" value="#{refundCashInAdvanceManagerBean.selectedSaleOrder.id}"/>                                         
                <p:message for="saleOrderId" /> 
                    
                <h:outputLabel for="date" style="font-weight: bold" value="Date: " /> 
                <h:outputText id="date" value="#{refundCashInAdvanceManagerBean.selectedSaleOrder.saleOrderDate}"/>                         
                <p:message for="date" /> 

                <p:column sortBy="#{lineItem.product.productType}">
                <f:facet name="header">
                        <h:outputText value="Type"/>
                </f:facet>
                <h:outputText value="#{lineItem.product.productType}"/>
                </p:column>
                
                <h:panelGrid columns="3" cellpadding="10"> 
                    <p:dataTable var="lineItem" value="#{refundCashInAdvanceManagerBean.selectedSaleOrder.lineItems}"
                                 dynamic="true" paginator="true" emptyMessage="No Line Item">
                        <f:facet name="header">
                            <h:outputText value="Sale Order Information"/>
                        </f:facet>
                        <p:column sortBy="#{lineItem.product.productType}">
                            <f:facet name="header">
                                <h:outputText value="Type"/>
                            </f:facet>
                            <h:outputText value="#{lineItem.product.productType}"/>
                        </p:column>
                        
                        
                    <p:column sortBy="#{lineItem.product.productPrice}">
                        <f:facet name="header">
                            <h:outputText value="Price per Unit"/>
                        </f:facet>
                        <h:outputText value="#{lineItem.product.productPrice}"/>
                    </p:column>
                    
                    <p:column>
                        <f:facet name="header">
                            <h:outputText value="Quantity"/>
                        </f:facet>
                        <h:outputText value="#{lineItem.lineItemQuantity}" />
                    </p:column>
                    
                    <p:column>
                        <f:facet name="header">
                            <h:outputText value="Volume Discount"/>
                        </f:facet>
                        <h:outputText value="#{lineItem.volumeDiscountRate}"/>                        
                    </p:column>
                    
                    <p:column>
                        <f:facet name="header">
                            <h:outputText value="Total Price"/>
                        </f:facet>
                        <h:outputText value="#{lineItem.finalPrice}"/>
                    </p:column>
                    
                    <f:facet name="footer">
                         <h:outputText value ="Total Price: "/>
                         <h:outputText value="#{refundCashInAdvanceManagerBean.selectedSaleOrder.totalPrice}"/>
                    </f:facet>
                
                    
                    </p:dataTable>
                                    </h:panelGrid>
                    <br/>
                    
                    <h:outputLabel for="customerName" style="font-weight: bold" value="Company Name: " /> 
                    <h:outputText value="#{refundCashInAdvanceManagerBean.selectedCustomer.saleLeadName}" id="customerName">
                    </h:outputText> 
                    <p:message for="customerName" /> 
                    
                    <h:outputLabel for="registrationNumber" style="font-weight: bold" value="Registration Number: " /> 
                    <h:outputText id="registrationNumber" value="#{refundCashInAdvanceManagerBean.selectedCustomer.registrationNumber}"> 
                    </h:outputText> 
                    <p:message for="registrationNumber" /> 
 
                    <h:outputLabel for="creditAccountId" style="font-weight: bold" value="Credit Account ID: " /> 
                    <h:outputText id="creditAccountId" value="#{refundCashInAdvanceManagerBean.selectedCustomer.creditAccount.creditAccountId}">                         
                    </h:outputText> 
                    <p:message for="creditAccountId" /> 
                    
                    <h:outputLabel for="deposit" style="font-weight: bold" value="Deposit ($): " /> 
                    <h:outputText id="deposit" value="#{refundCashInAdvanceManagerBean.selectedCustomer.creditAccount.deposit}">                         
                    </h:outputText> 
                    <p:message for="deposit" /> 
                    
                    <h:outputLabel for="creditLimit" style="font-weight: bold" value="Credit Limit: " /> 
                    <h:outputText id="creditLimit" value="#{refundCashInAdvanceManagerBean.selectedCustomer.creditAccount.creditLimit}">                         
                    </h:outputText> 
                    <p:message for="creditLimit" />
                    
                    <h:outputLabel for="creditBalance" style="font-weight: bold" value="Credit Balance: " /> 
                    <h:outputText id="creditBalance" value="#{refundCashInAdvanceManagerBean.selectedCustomer.creditAccount.creditBalance}">                         
                    </h:outputText> 
                    <p:message for="creditBalance" />
                    
                    <h:outputLabel for="cashInAdvance" style="font-weight: bold" value="Cash In Advance: " /> 
                    <h:outputText id="cashInAdvance" value="#{refundCashInAdvanceManagerBean.selectedSaleOrder.cashInAdvance.cashInAdvanceAmount}">                         
                    </h:outputText> 
                    <p:message for="cashInAdvance" />
                    
                <p:commandButton value="Refund Cash In Advance" update="panel" actionListener="#{refundCashInAdvanceManagerBean.refundCashInAdvance}" ajax="false" />
                </p:panel> 
        </h:form>
        </f:view>
        
    </ui:define>

</ui:composition>
